package com.prawn.user.config;

import com.prawn.user.intercepter.JwtIntercepter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @Auther: zhy
 * @Date: 2019/7/11
 * @Description: 声明拦截对象
 */
@Component
public class IntercepterConfig extends WebMvcConfigurationSupport {

    @Autowired
    private JwtIntercepter jwtIntercepter;

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器要声明拦截器对象和要拦截的请求
        registry.addInterceptor(jwtIntercepter)
                .addPathPatterns("/**")
                //除了登录不拦截
                .excludePathPatterns("/**/login/**");
    }
}
